package com.qianbao.qianbaobusiness.ui.dialog;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetDialog;
import android.view.View;

import com.qianbao.qianbaobusiness.R;

public class PicAndCamSelectDialog extends BottomSheetDialog implements View.OnClickListener {

    View fl_image_select_id;
    View fl_camra_select_id;
    View fl_cancel_select_id;

    onItemSelectClick mOnItemSelectClick;

    public PicAndCamSelectDialog(@NonNull Context context, onItemSelectClick onItemSelectClick) {
        super(context);
        setupView();
        mOnItemSelectClick = onItemSelectClick;
    }

    private void setupView() {
        setContentView(R.layout.pic_cam_select_layout);
        fl_image_select_id = findViewById(R.id.fl_image_select_id);
        fl_camra_select_id = findViewById(R.id.fl_camra_select_id);
        fl_cancel_select_id = findViewById(R.id.fl_cancel_select_id);
        fl_image_select_id.setOnClickListener(this);
        fl_camra_select_id.setOnClickListener(this);
        fl_cancel_select_id.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {

            case R.id.fl_image_select_id:
                if (mOnItemSelectClick != null) {
                    mOnItemSelectClick.onImageSelect();
                }
                dismiss();
                break;

            case R.id.fl_camra_select_id:
                if (mOnItemSelectClick != null) {
                    mOnItemSelectClick.onCamaraSelect();
                }
                dismiss();
                break;

            case R.id.fl_cancel_select_id:
                dismiss();
                break;

            default:
                break;
        }
    }


    public interface onItemSelectClick {
        void onImageSelect();

        void onCamaraSelect();
    }
}